home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / nodlst.arc / IPXLIBR.ASM < prev    next >
Assembly Source File  |  1989-10-16  |  6KB  |  279 lines

  1. ;
  2. ; IPXLIB.ASM    -  Library of ASM routines for IPX/SPX
  3. ;
  4.     .MODEL SMALL
  5.  
  6.     .DATA
  7.     ;Address of IPX
  8.     IPXAddress dw 2 dup(0)
  9.  
  10.     .CODE
  11.  
  12.     PUBLIC _IPXInitialize
  13.     PUBLIC _IPXOpenSocket
  14.     PUBLIC _IPXCloseSocket
  15.     PUBLIC _IPXGetLocalTarget
  16.     PUBLIC _IPXSendPacket
  17.     PUBLIC _IPXListenForPacket
  18.     PUBLIC _IPXRelinquishControl
  19.     PUBLIC _IPXGetIntervalMarker
  20.     PUBLIC _SPXEstablishConnection
  21.     PUBLIC _SPXListenForSequencedPacket
  22.     PUBLIC _SPXSendSequencedPacket
  23.     PUBLIC _SPXTerminateConnection
  24.  
  25.  
  26. ; int IPXInitialize( void );
  27. ;  Initializes IPX/SPX mechanism, returns TRUE if IPX is installed,
  28. ;  FALSE (0) if not installed.
  29. ;
  30. _IPXInitialize    proc near
  31.     mov    ax, 7A00h            ; Looking for address of 7Ah
  32.     int    2Fh                ; Call Multiplex interrupt
  33.     mov    IPXAddress, di            ; Store address
  34.     mov    IPXAddress + 2, es
  35.     and    ax, 00FFh            ; Mask off AH to return status in AL
  36.     ret
  37. _IPXInitialize    endp
  38.  
  39. ; int IPXOpenSocket(BYTE *socketNumber, BYTE socketType);
  40. ;  Opens socket socketNumber as socketType (either Temporary or Permanent)
  41. ;  Returns 0 on success.
  42. ;
  43. _IPXOpenSocket    proc near
  44.     push    bp                ; Establish standard parameter frame
  45.     mov    bp, sp
  46.  
  47.     mov    bx, [bp + 4]            ; Place socketNumber in high-low order
  48.     mov    dl, byte ptr [bx]
  49.     mov    dh, byte ptr [bx + 1]
  50.     mov    al, [bp + 6]            ; AL gets socketType
  51.     mov    bx, 0
  52.     call dword ptr DGROUP:IPXAddress    ; Make far call to IPXAddress
  53.  
  54.     pop     bp                ; Restore stack frame & return
  55.     and    ax, 00FFh
  56.     ret
  57. _IPXOpenSocket    endp
  58.  
  59. ; void IPXCloseSocket(WORD socketNumber);
  60. ;  Close socket socketNumber.
  61. ;
  62. _IPXCloseSocket    proc near
  63.     push    bp
  64.     mov    bp, sp
  65.  
  66.     mov    bx, [bp + 4]
  67.     mov    dx, bx
  68.     mov    bx, 1
  69.     call dword ptr DGROUP:IPXAddress
  70.  
  71.     pop    bp
  72.     ret
  73. _IPXCloseSocket    endp
  74.  
  75. ; int IPXGetLocalTarget(BYTE *networkAddress,BYTE *immediateAddress,WORD *transportTime);
  76. ;  A 10-byte networkAddress is passed to IPX, which returns the immediteAddress
  77. ;  to be placed in the ECB and transportTime, an estimate (in clock ticks) of the
  78. ;  time to send the packet from the source to the destination node.
  79. ;  Returns 0 on success.
  80. ;
  81. _IPXGetLocalTarget    proc near
  82.     push    bp
  83.     mov    bp, sp
  84.  
  85.     push     si
  86.     mov    bx, [bp + 4]
  87.     mov    si, bx
  88.     mov    bx, [bp + 6]
  89.     mov    di, bx
  90.     mov    bx, 2
  91.     call dword ptr DGROUP:IPXAddress
  92.  
  93.     mov    bp, sp                    ; restore BP (IPX kills it)
  94.     add    bp, 2                    ; account for SI push
  95.     mov    bx, [bp + 8]                ; get address of
  96.     mov    [bx], cx                ; place CX at *
  97.  
  98.     pop    si
  99.     pop    bp
  100.     and    ax, 00FFh
  101.     ret
  102. _IPXGetLocalTarget    endp
  103.  
  104. ; void IPXSendPacket(ECB *eventControlBlock);
  105. ;  Sends an IPX packet.
  106. ;
  107. _IPXSendPacket    proc near
  108.     push    bp
  109.     mov    bp, sp
  110.     push     si
  111.  
  112.     mov     ax, DGROUP
  113.     mov    es, ax
  114.     mov    bx, [bp + 4]
  115.     mov    si, bx
  116.     mov    bx, 3
  117.  
  118.     call dword ptr DGROUP:IPXAddress
  119.  
  120.     push    ds
  121.     pop    es
  122.     pop    si
  123.     pop     bp
  124.     ret
  125. _IPXSendPacket    endp
  126.  
  127. ; int IPXListenForPacket(ECB *eventControlBlock);
  128. ;  Listens for an IPX packet using the passed Event Control Block.
  129. ;  Returns 0 if able to post the listen request.
  130. ;
  131. _IPXListenForPacket    proc near
  132.     push    bp
  133.     mov    bp, sp
  134.     push    si
  135.  
  136.     mov     ax, DGROUP
  137.     mov    es, ax
  138.     mov    bx, [bp + 4]
  139.     mov    si, bx
  140.     mov    bx, 4
  141.  
  142.     call dword ptr DGROUP:IPXAddress
  143.  
  144.     push    ds
  145.     pop    es
  146.     pop    si
  147.     pop     bp
  148.     and    ax, 00FFh
  149.     ret
  150. _IPXListenForPacket    endp
  151.  
  152. ; void IPXRelinquishControl(void);
  153. ;  Relinquishes control to IPX for other processing.
  154. ;
  155. _IPXRelinquishControl    proc near
  156.     mov    bx, 0Ah
  157.     call dword ptr DGROUP:IPXAddress
  158.     ret
  159. _IPXRelinquishControl    endp
  160.  
  161. ; unsigned int IPXGetIntervalMarker(void);
  162. ;  Gets a timer tick marker from IPX.
  163. ;
  164. _IPXGetIntervalMarker    proc near
  165.     mov    bx, 8
  166.     call dword ptr DGROUP:IPXAddress
  167.     ret
  168. _IPXGetIntervalMarker    endp
  169.  
  170. ; int SPXEstablishConnection( BYTE RetryCount, BYTE Watchdog, WORD *connectionID, ECB *ECBptr );
  171. ;  Makes an SPX connection with the target listening node.
  172. ;  Returns 0 if able to attempt connection.
  173. ;
  174. _SPXEstablishConnection    proc near
  175.     push    bp
  176.     mov    bp, sp
  177.     push    si
  178.  
  179.     mov     ax, DGROUP
  180.     mov    es, ax
  181.  
  182.     mov    bx, [bp + 4]
  183.     mov    al, bl
  184.     mov    bx, [bp + 6]
  185.     mov    ah, bl
  186.     mov    bx, [bp + 10]
  187.     mov    si, bx
  188.     mov    bx, 11h
  189.  
  190.     call dword ptr DGROUP:IPXAddress
  191.  
  192.     mov    bp, sp                    ; restore BP (IPX kills it)
  193.     add    bp, 2                    ; account for SI push
  194.     mov    bx, [bp + 8]                ; get address of
  195.     mov    [bx], dx                ; place DX at *
  196.  
  197.     push    ds
  198.     pop    es
  199.     pop    si
  200.     pop     bp
  201.     and    ax, 00FFh
  202.     ret
  203. _SPXEstablishConnection    endp
  204.  
  205. ; void SPXListenForSequencedPacket( ECB *ECBptr );
  206. ;  Posts a listening ECB to receive an SPX packet.
  207. ;
  208. _SPXListenForSequencedPacket    proc near
  209.     push    bp
  210.     mov    bp, sp
  211.     push    si
  212.  
  213.     mov     ax, DGROUP
  214.     mov    es, ax
  215.     mov    bx, [bp + 4]
  216.     mov    si, bx
  217.     mov    bx, 17h
  218.  
  219.     call dword ptr DGROUP:IPXAddress
  220.  
  221.     push    ds
  222.     pop    es
  223.     pop    si
  224.     pop     bp
  225.     ret
  226. _SPXListenForSequencedPacket    endp
  227.  
  228. ; void SPXSendSequencedPacket( WORD ConnectionID, ECB *ECBptr );
  229. ;  Sends an SPX packet.
  230. ;
  231. _SPXSendSequencedPacket    proc near
  232.     push    bp
  233.     mov    bp, sp
  234.     push    si
  235.  
  236.     mov     ax, DGROUP
  237.     mov    es, ax
  238.     mov    bx, [bp + 4]
  239.     mov    dx, bx
  240.     mov    bx, [bp + 6]
  241.     mov    si, bx
  242.     mov    bx, 16h
  243.  
  244.     call dword ptr DGROUP:IPXAddress
  245.  
  246.     push    ds
  247.     pop    es
  248.     pop    si
  249.     pop     bp
  250.     ret
  251. _SPXSendSequencedPacket    endp
  252.  
  253. ; void SPXTerminateConnection( WORD ConnectionID, ECB *ECBptr );
  254. ;  Terminates an SPX connection.
  255. ;
  256. _SPXTerminateConnection    proc near
  257.     push    bp
  258.     mov    bp, sp
  259.     push    si
  260.  
  261.     mov     ax, DGROUP
  262.     mov    es, ax
  263.     mov    bx, [bp + 4]
  264.     mov    dx, bx
  265.     mov    bx, [bp + 6]
  266.     mov    si, bx
  267.     mov    bx, 13h
  268.  
  269.     call dword ptr DGROUP:IPXAddress
  270.  
  271.     push    ds
  272.     pop    es
  273.     pop    si
  274.     pop     bp
  275.     ret
  276. _SPXTerminateConnection    endp
  277.  
  278.     END
  279.